package o2o.dao.TO.sync;

import com.jinyou.utils.common.DateUtils;
import lombok.Data;
import lombok.experimental.Accessors;
import o2o.dao.PO.order.ORDER_STATUS;
import o2o.dao.PO.order.OrderInfo;
import o2o.utils.OrderUtils;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Jahnke【1029777564@qq.com】
 * @ClassName CloudOrderShopTO_Yiyi
 * @Description:
 * @date 2019/8/24 9:40
 * @Version 1.0
 */
@Data
@Accessors(chain = true)
public class CloudOrderShopTO_Yiyi {

    /********商户信息*********/
    private String shopName;
    private String shopPhone;
    private String shopImageUrl;
    private String shopAddress;
    private Double shopLat;
    private Double shopLng;
    private Long shopId;

    private List<OrderGoodsTO> goods = new ArrayList<>();

    // 转订单信息
    public OrderInfo convertInfo(OrderInfo masterOrder) {
        // 根据typeId转换typeCode
        OrderInfo order = new OrderInfo();
        String orderNo = OrderUtils.getOrderNo();
        BeanUtils.copyProperties(this, order);
        order.setOrderNo(orderNo).setParentOrderNo(masterOrder.getOrderNo()).setPayOrderNo(masterOrder.getOrderNo());
        order.setOrderStatus(ORDER_STATUS.SHOP_SURE).setShopSelfPost(0);
        order.setCreateTime(DateUtils.getCurrTime());
        order.setOrderType(masterOrder.getOrderType());

        return order;
    }
}
